import openpyxl
import os
import time

DEBUG=True
def debug_print(*p):
    if DEBUG:
        print(*p)
def init():
    if not os.path.exists('Data'):
        os.makedirs('Data')
#读出路径下的所有文件
def read_files():
    localPath = './Data/'
    files = []
    for i in os.listdir(localPath):
        #if i == 'allData.xlsx' or i == 'wx_record.xlsx':
            #continue
        files.append(''.join([localPath, i]))
    return files
#新建一个文件
def new_file(name):
    wb = openpyxl.Workbook()
    sheet = wb.active
    sheet.title = 'sheet1'
    sheet['A1'].value = '姓名：'
    sheet['B1'].value =name
    sheet['A2'].value = '期数'
    sheet['B2'].value = '大'
    sheet['C2'].value = '小'
    sheet['D2'].value = '单'
    sheet['E2'].value = '双'
    sheet['F2'].value = '小单'
    sheet['G2'].value = '小双'
    sheet['H2'].value = '大单'
    sheet['I2'].value = '大双'
    sheet['J2'].value = '结算'
    sheet['K2'].value = '数字'
    curTime = time.localtime()
    #print(str(curTime.tm_mon) + "-" + str(curTime.tm_mday))
    name = './Data/'+name + str(curTime.tm_mon) + "-" + str(curTime.tm_mday) + '.xlsx'
    wb.save(name)

    return wb,sheet
